package net.wanho.controller;

import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import net.wanho.service.FileService;
import net.wanho.vo.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * Author：汤小洋
 * Date：2024-10-23 11:02
 * Description：<描述>
 */
@RestController
@RequiredArgsConstructor
public class FileController {

    private final FileService fileService;

    @SneakyThrows
    @PostMapping("/upload")
    public R upload(MultipartFile file){
        // System.out.println(file.getOriginalFilename());
        // System.out.println(file.getSize());
        // System.out.println(file.getContentType());
        // System.out.println(file.getInputStream());

        String url = fileService.uploadFile(file);
        return R.success("文件上传成功！", url);
    }
}
